Debian 7.0
Sponsored Link

Rsync - Sync Files/Directories
2013/06/05
 
Synchronizes files and directories from one location to another by rsync. Basic usage of rsync is here.
The example below is for automatical settings.
example ⇒ Copy files and directories in /var/www/html on a HostA[10.0.0.31] to in /home/backup on HostB[10.0.0.30].
[1] Configure on Destination Host
root@dlp:~#
aptitude -y install rsync
root@dlp:~#
vi /etc/default/rsync
# line 8: change

RSYNC_ENABLE=
true
root@dlp:~#
vi /etc/rsyncd.conf
# define any name you like

[site]
# Destination Directory

path = /home/backup
# Hosts you allow to copy (specify source Host)

hosts allow = 10.0.0.31
hosts deny = *
list = true
uid = root
gid = root
read only = false
root@dlp:~#
mkdir /home/backup

root@dlp:~#
/etc/init.d/rsync start

Starting rsync daemon: rsync.
[2] Configure on Source Host
root@www:~#
aptitude -y install rsync
root@www:~#
vi /etc/rsync_exclude.lst
# specify files or directories you'd like to exclude to copy

test
test.txt

[3] It's OK. Execute rsync on Source Host like follows.
root@www:~#
rsync -avz --delete --exclude-from=/etc/rsync_exclude.lst /var/www/ 10.0.0.30::site
# Add in cron if you'd like to run reguraly

root@www:~#
# run at 2:00 AM every day

00 02 * * * rsync -avz --delete --exclude-from=/etc/rsync_exclude.lst /var/www/ 10.0.0.30::site
 
Tweet